import DList from "@/components/dlist";
export default {
  data() {
    return {
      reward_type: 1,
      tabList: [{
        id: 1,
        name: "技能师傅奖励记录"
      },{
        id: 2,
        name: "师傅推荐人奖励记录"
      }],
      loading: false,
      finished: false,
      page: 1,
      recordList: [],
      detailData: {}
    };
  },
  mounted() {
    this.getCentreData();
    this.getData();
  },
  methods: {
    async getCentreData() {
      let { data, result, msg } = await $http.get("plugin.be-within-call.frontend.manage.reward-centre", {  });
      console.log(data, result, msg,333);
      if (result === 0) {
        this.$toast(msg);
        return;
      }
      this.detailData = data;
    },
    async getData() {
      if (this.loading === true || this.finished === true) {
        return;
      }
      this.loading = true;
      let { data, result, msg } = await $http.get("plugin.be-within-call.frontend.manage.get-dividend", { page:this.page, reward_type: this.reward_type });
      console.log(data, result, msg,333);
      if (result === 0) {
        this.$toast(msg);
        return;
      }
      if (data.data.length === 0 || data.data.length < data.per_page || data.current_page === data.last_page) {
        this.finished = true;
      }
      this.total = data.total;
      this.recordList.push(...data.data);
      this.page++;
      this.loading = false;
    },
    onLoad() {
      this.getData();
    },
    clickTab() {
      this.loading = false;
      this.finished = false
      this.page = 1;
      this.recordList = [];
      this.getData();
      console.log(1111);
    }
  },
  components: { DList }
};
